<?php
/**
 * This file generates a RSS Feed for a given tool
 * The tool should be provided in the gVAR array as the variable gVAR['tool'] 
 */

if(isset($gVAR['tool']) === true) {
    
    try {
	header('Content-type: application/rss+xml; charset=ISO-8859-1');
	$Project =& $ProjectStash->stash($gVAR['tool']);
	$TemplateEngine->setTitle($Project->getName());
	$Project->instanciate();
	$RSS = new RSSFeed($Project->getName().' News Feed', EclipseMDE::aliasLink($Project->getAlias()), 'Aggregated RSS for '.$Project->getName(), $copyrightNotice);
	require_simplepie();
	$SimplePieA = new SimplePieAggregator($Project->getRSSfeeds());
	$SimplePieA->aggregate();
	$items =& array_splice($SimplePieA->get_items(), 0, 15);
	foreach($items as $key => $value) {
	    $date = $value->get_date();
	    $title = $value->get_title();
	    $url = $value->get_permalink();
	    $description = $value->get_description();
	    /*$icon = '';//$value->getIconURL();*/
	    $RSS->addItem($title, $description, $url, $date);
	}
	$RSS->render();
	die();
    } catch(InvalidProjectException $e) {
	/* 404 */
    } catch(Exception $e) {
	$gVAR['e'] = 500;
	require_once($_ECLIPSEMDE['ROOT_WD'].'www-root/error_handler.php');
	die();
    }
} else {
    // 404
}

    // let the catch and else blocks fall through to the 404 
    $gVAR['e'] = 404;
    require_once($_ECLIPSEMDE['ROOT_WD'].'www-root/error_handler.php');
    die();
?>
